﻿<%@ Page Title="Wild2" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Wild2.Models.Pages.User.Subscr>" %>
<asp:Content ID="TitleContent" ContentPlaceHolderID="TitleContent" runat="server">
    <%= Resources.Home.Title %>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="HeaderBlockContent" runat="server">
<%--Keywords--%>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="HeaderContent" runat="server">
    <%  String version = "pda"; if (Session[Wild2.Models.Constants.SessionConstants.VERSION] != null) version = Session[Wild2.Models.Constants.SessionConstants.VERSION].ToString(); %>
    <% Html.RenderPartial("~/Views/Shared/" + version + "/Header.ascx", "Подписчики пользователя"); %>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%  String version = "pda"; if (Session[Wild2.Models.Constants.SessionConstants.VERSION] != null) version = Session[Wild2.Models.Constants.SessionConstants.VERSION].ToString(); %>
    <% if (!String.IsNullOrEmpty(Model.infoMessage))
       {
           Html.RenderPartial("~/Views/Shared/" + version + "/InfoBox.ascx", Model.infoMessage);
       } %>
       <div class="container">
        <% Html.RenderPartial("~/Views/Shared/" + version + "/Panel.ascx", "Подписаны " + Model.UsersData.Count + " пользовател(я|ей)"); %>
        <% 
            if (Model.UsersData.Count > 0)
            {
                foreach (var user in Model.UsersData)
                {
                    String online = "";
                    int onlinetime = 15;
                    if (ConfigurationManager.AppSettings["onlinetime"] != null) { onlinetime = Int32.Parse(ConfigurationManager.AppSettings["onlinetime"]); }
                    if (user.LastOnlineDate.AddMinutes(onlinetime).CompareTo(DateTime.Now) > 0) online = "online";

                    int age = 0;
                    if (user.Birth.HasValue)
                    {
                        DateTime birth = user.Birth.Value;
                        age = DateTime.Now.Year - birth.Year;
                        if ((DateTime.Now.Month < birth.Month) || ((DateTime.Now.Month == birth.Month) && (DateTime.Now.Day < birth.Day))) age--;
                    }

                    Html.RenderPartial("~/Views/Shared/" + version + "/Element.ascx", Html.ActionLink(user.Nick, "Index", new { id = user.ID }, new { @class = online }) +
                                                                                      " " + ((user.isMale.HasValue) ? ((user.isMale.Value) ? ("М") : ("Ж")) : ("")) +
                                                                                      ((user.Birth.HasValue) ? (" " + age) : (""))
                                                                                      );
                }
            }
            else
            {
                Html.RenderPartial("~/Views/Shared/" + version + "/Element.ascx", "Подписчиков нет");    
            }
        %>
        <% 
            int id = Convert.ToInt32(Url.RequestContext.RouteData.Values["id"]);
            if (id >= 0) Html.RenderPartial("~/Views/Shared/" + version + "/Panel.ascx", Html.ActionLink("Посмотреть на кого подписан он", "Subscr", new { id = (Math.Abs(id) * -1) }));
            else Html.RenderPartial("~/Views/Shared/" + version + "/Panel.ascx", Html.ActionLink("Посмотреть кто подписан на него", "Subscr", new { id = Math.Abs(id) }));
        %>
        </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="FooterContent" runat="server">
    <%  String version = "pda"; if (Session[Wild2.Models.Constants.SessionConstants.VERSION] != null) version = Session[Wild2.Models.Constants.SessionConstants.VERSION].ToString(); %>
    <% Html.RenderPartial("~/Views/Shared/" + version + "/Footer.ascx");
        %>
</asp:Content>